public class Test {
    public static void yangHui(int n){
        int[][] arr=new int[n][n];
        for(int i=0;i<=n-1;i++){
            arr[i][0]=1;
            arr[i][i]=1;
            if(i>1) {
                for (int j = 1; j < i; j++) {
                    arr[i][j]=arr[i-1][j-1]+arr[i-1][j];
                }
            }
        }
        //正三角
     /*   for(int i=0;i<n;i++){
            for (int k = 1; k <n-i; k++) {
                System.out.print(" ");
            }
            for (int j = 0; j <=i; j++) {
                System.out.print(arr[i][j]+" ");
            }
            System.out.println();
        }*/
        //倒三角
        for(int i=n-1;i>=0;i--){
            for (int k = 1; k <n-i; k++) {
                System.out.print(" ");
            }
            for (int j = 0; j <=i; j++) {
                System.out.print(arr[i][j]+" ");
            }
            System.out.println();
        }


    }

    public static void main(String[] args) {
        yangHui(5);
    }
}
